﻿namespace FlickrDownloadr
{
    using Autofac;
    using FlickrDownloadr.Features.About;

    /// <summary>
    /// Inversion of Control container that handles loading of View Models and other types during runtime.
    /// </summary>
    public class ObjectContainer
    {
        public IContainer Build()
        {
            ContainerBuilder builder = new ContainerBuilder();
            builder.RegisterModule(new FeaturesModule());
            builder.RegisterModule(new FrameworkModule());
            builder.RegisterModule(new ServicesModule());

            var container = builder.Build();
            return container;

        
            //builder.Register(container =>
            //{

            //    var aboutController = container.Resolve<AboutController>();
            //    return aboutController.CreateAboutView();
            //});

            //builder.Register(c => new AutofacServiceLocator(c.Resolve<IComponentContext>()));

            // This is only done until we can find a way to instantiate an instance automatically on build.
            //var aboutController = container.Resolve<AboutController>();

            // Hand the container to the CommonServiceLocator and return to the framework
            //var csl = container.Resolve<IServiceLocator>();
            //return csl;
        }
    }
}
